#include <iostream>
#include <vector>
#include<map>

using namespace std;

bool isvisited[100010];
int a[100010];
int sum = 0;
int n;
int count = 0;

map<int,bool> mp; //利用map保存已经存在的和

int dfs(int step, int depth)
{

    if (step > depth)
    {
        return 0;
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            if (!isvisited[i])
            {
                sum += a[i];
                if (sum > 0 && !mp[sum])
                {
                    count++;
                    mp[sum] = true;
                }
                isvisited[i] = true;
                int temp = dfs(step + 1, depth);
                sum -= a[i];
                isvisited[i] = false;
            }
        }
    }
    return count;
}

int main()
{
    int total = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    total += dfs(1, n - 1);
    cout << total << endl;
    system("pause");
    return 0;
}